<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="javatime" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<% String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<html>
<head>
    <base href=<%=basePath%>
          <%@include file="../common_css.jsp"%>
                  <style>
    .layui-upload-img{
    width: 92px;
    height: 92px;
    margin: 0 10px 10px 110px;
    }
    </style>
</head>
<body class="childrenBody">
<form class="layui-form" style="width:80%;">
    <input type="hidden" name="inputId" id="inputId" value="${customer.id}">
    <div class="layui-form-item layui-row">
        <div class="layui-col-xs6">
            <label class="layui-form-label">客户姓名</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input"
                       lay-verify="required" name="name" id="name"  value="${customer.name}">
            </div>
        </div>
        <div class="layui-col-xs6">
            <label class="layui-form-label">手机号</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input"
                       lay-verify="phone" name="phone" id="phone"  value="${customer.phone}"
                >
            </div>
        </div>
    </div>


    <div class="layui-form-item layui-row">
        <div class="layui-col-xs6">
            <label class="layui-form-label">微信号</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input"
                       lay-verify="required" name="weixin" id="weixin"  value="${customer.weixin}"
                >
            </div>
        </div>
        <div class="layui-col-xs6">
            <label class="layui-form-label">客户来源</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input"
                       lay-verify="required" name="stringSource" id="stringSource"  value="${customer.activity.name}"
                       readonly
                >
            </div>
        </div>
    </div>

    <div class="layui-form-item layui-row">
        <div class="layui-col-xs6">
            <label class="layui-form-label">状态</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input"
                       lay-verify="required" name="state" id="state"  value="${customer.stringCustomerState}"
                       readonly
                >
            </div>
        </div>
        <div class="layui-col-xs6">
            <label class="layui-form-label">员工</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input"
                       lay-verify="required" name="user" id="user"  value="${customer.user.name}"
                       readonly
                >
            </div>
        </div>
    </div>
    <br/>
    <div class="layui-form-item layui-row layui-col-xs12">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-lg" lay-submit=""
                    lay-filter="updateCustomer">确认
            </button>
            <button class="layui-btn layui-btn-lg layui-btn-normal">取消</button>
        </div>
    </div>

</form>
<script type="text/javascript">
    layui.use(['form', 'layer','laydate','upload'], function () {
        var form = layui.form,
            layer = parent.layer === undefined ? layui.layer : top.layer,
            $ = layui.jquery
            ,upload = layui.upload;


        form.on('submit(updateCustomer)',function (data) {
            var index= top.layer.msg("数据提交中,请稍后...",{icon:16,time:false,shade:0.8});
            var url = "/customer/updateCustomer";
            $.post(url,{id:$("#inputId").val(),phone:$("#phone").val(),weixin:$("#weixin").val(),name:$("#name").val()},function (res) {
                if(res=='success'){
                    top.layer.msg("操作成功");
                    top.layer.close(index);
                    layer.closeAll("iframe");
                    // 刷新父页面
                    parent.location.reload();
                }
            });
            return false;
        });
    });
</script>
</body>
</html>